home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header *** Header built automatically - do not edit! ***********
- *
- * (C) Copyright 1991 by Torsten Jürgeleit
- *
- * Name .....: main.c
- * Created ..: Sunday 22-Dec-91 21:22:47
- * Revision .: 2
- *
- * Date Author Comment
- * ========= ==================== ====================
- * 02-Oct-92 Michael Bjerking New realese, better Screen/Window editor
- * 02-Oct-92 Michael Bjerking Arp library replaced by ReqTools
- * 22-Dec-91 Torsten Jürgeleit Created this file!
- *
- ****************************************************************************
- *
- * Main part
- *
- * $Revision Header ********************************************************/
-
- /* Includes */
-
- #include "includes.h"
- #include "defines.h"
- #include "imports.h"
- #include "protos.h"
-
- /* Globals */
-
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- struct ArpBase *ArpBase;
- struct Library *IntuiSupBase = NULL; /* Clear for show_error() */
- struct ReqToolsBase *ReqToolsBase;
-
- /*
- struct Library *DiskfontBase;
- struct Library *LayersBase;
- */
-
- struct Screen wb_screen;
- struct Window *ewin, *pwin;
- struct TextAttr topaz60_attr =
- {(STRPTR) "topaz.font", TOPAZ_SIXTY,
- FS_NORMAL, FPF_ROMFONT}, topaz80_attr =
- {
- (STRPTR) "topaz.font", TOPAZ_EIGHTY,
- FS_NORMAL, FPF_ROMFONT
- };
- STATIC struct NewWindow editor_new_window =
- {
- EDITOR_WINDOW_LEFT, EDITOR_WINDOW_TOP, EDITOR_WINDOW_WIDTH,
- EDITOR_WINDOW_HEIGHT, EDITOR_WINDOW_DETAIL_PEN, EDITOR_WINDOW_BLOCK_PEN,
- EDITOR_WINDOW_IDCMP, EDITOR_WINDOW_FLAGS, NULL, NULL,
- (UBYTE *) & editor_window_title[0], NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
- };
- struct NewWindow project_new_window =
- {
- 0, 0, 0, 0, PROJECT_WINDOW_DETAIL_PEN, PROJECT_WINDOW_BLOCK_PEN,
- PROJECT_WINDOW_IDCMP, PROJECT_WINDOW_FLAGS, NULL, NULL,
- PROJECT_WINDOW_TITLE, NULL, NULL, PROJECT_WINDOW_MIN_WIDTH,
- PROJECT_WINDOW_MIN_HEIGHT, -1, -1, WBENCHSCREEN
- };
-
- struct TemplateList template_list;
- struct Template *selected_template, *info_template;
- struct Box current_box;
-
- struct GadgetData *use_gd;
- struct rtFileRequester *project_file_requester, *csource_file_requester;
-
- struct Dimension min_dimension[MAX_TEMPLATE_TYPES] =
- {
- {20, 10},
- {0, 0},
- {20, 10},
- {21, 11},
- {50, 10},
- {30, 8},
- {30, 8},
- {20, 8},
- {20, 8},
- {50, 10},
- {40, 10},
- {40, 30},
- {60, 30}};
-
- APTR eri, pri, egl, eml, use_gl;
-
- BYTE *default_mx_text_array[]=
- {"MX1", "MX2", NULL}, *default_cycle_text_array[]=
- {"Cycle", "Test 1", "Test 2", NULL}, *default_listview_text_array[]=
- {"Entry 1", "Entry 2", "Entry 3",
- "Entry 4", "Entry 5", "Entry 6", "Entry 7", "Entry 8",
- "Entry 9", "Entry 10", NULL};
- BYTE editor_window_title[MAX_PROJECT_NAME_LEN + 3], editor_screen_title[MAX_PROJECT_NAME_LEN + 1], project_window_title[80];
-
- USHORT snap_offset_table[]=
- {1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
-
- USHORT editor_mode = DEFAULT_EDITOR_MODE, snap_offset = DEFAULT_SNAP_OFFSET, template_type = DEFAULT_TEMPLATE_TYPE;
-
- USHORT modify_mode = 0, mouse_button = 0;
- SHORT last_snap_x, last_snap_y;
-
- BOOL info_displayed = FALSE;
-
- /* Main routine */
-
- LONG
- main(VOID)
- {
- LONG return_code = RETURN_ERROR;
-
- MWInit((BPTR) NULL, (LONG) MWF_NOATRASH);
- if (IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L))
- {
- if (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L))
- {
- if (!(ReqToolsBase = (struct ReqToolsBase *) OpenLibrary(REQTOOLSNAME, REQTOOLSVERSION)))
- show_error(EDITOR_ERROR_NO_REQTOOLS);
- else
- {
- if (!(IntuiSupBase = (struct Library *) OpenLibrary(IntuiSupName, IntuiSupVersion)))
- show_error(EDITOR_ERROR_NO_INTUISUP);
- else
- {
- return_code = init_resources();
- CloseLibrary(IntuiSupBase);
- }
- CloseLibrary((struct Library *) ReqToolsBase);
- }
- CloseLibrary((struct Library *) GfxBase);
- }
- CloseLibrary((struct Library *) IntuitionBase);
- }
- MWTerm();
-
- return (return_code);
- }
-
- /* Init resources */
-
- LONG
- init_resources(VOID)
- {
- SHORT status;
- LONG return_code = RETURN_OK;
-
- GetScreenData((BYTE *) & wb_screen, (LONG) sizeof(struct Screen), (LONG)
- WBENCHSCREEN, (struct Screen *) NULL);
- /* Init and open editor window */
- if (!(eri = IGetRenderInfo((struct Screen *) NULL,
- EDIT_RENDER_INFO_FLAGS)))
- {
- status = EDITOR_ERROR_OUT_OF_MEM;
- }
- else
- {
- editor_new_window.LeftEdge = (wb_screen.Width -
- editor_new_window.Width) / 2;
- if (!(ewin = IOpenWindow(eri, &editor_new_window,
- EDIT_OPEN_WINDOW_FLAGS)))
- {
- status = EDITOR_ERROR_NO_WINDOW;
- }
- else
- {
-
- /* Init Template IDCMP flag */
- template_list.tl_IDCMPFlags = EDITOR_WINDOW_IDCMP;
-
- /* Init and open project window */
- pri = NULL;
- pwin = NULL;
- if ((status = new_project_window(&template_list,
- TEMPLATE_LIST_FLAG_DEFAULT_WINDOW)) == EDITOR_STATUS_NORMAL)
- {
-
- /* Init ReqTools file requester structs */
- if (!(project_file_requester = (struct rtFileRequester *)rtAllocRequestA(RT_FILEREQ, NULL)))
- {
- status = EDITOR_ERROR_OUT_OF_MEM;
- }
- else
- {
- if (!(csource_file_requester = (struct rtFileRequester *)rtAllocRequestA(RT_FILEREQ, NULL)))
- {
- status = EDITOR_ERROR_OUT_OF_MEM;
- }
- else
- {
- status = editor_action_loop();
- }
- }
- }
- rtFreeRequest((APTR)project_file_requester);
- rtFreeRequest((APTR)csource_file_requester);
-
- /* Free resources */
- if (pwin)
- {
- ICloseWindow(pwin, FALSE);
- }
- if (pri)
- {
- IFreeRenderInfo(pri);
- }
- ICloseWindow(ewin, FALSE);
- }
- IFreeRenderInfo(eri);
- }
- if (status < EDITOR_STATUS_NORMAL)
- {
- show_error(status);
- return_code = RETURN_ERROR;
- }
- return (return_code);
- }
-